const request = require('./request.js');

// 获取城市
exports.fetchCity = function (latitude, longitude) {
    let url = `http://api.map.baidu.com/geocoder/v2/?location=${latitude},${longitude}&output=json&ak=WEc8RlPXzSifaq9RHxE1WW7lRKgbid6Y`
    return request({
        url
    })
}

// 获取热映数据
exports.fetchHotMovie = function (page, pagesize) {
    return request({
        url: `http://mpmaoyanapi.crashcold1023.icu/comingList?page=${page}&pagesize=${pagesize}`
    })
}
//获取待映数据
exports.fetchwaitMovie = function () {
    return request({
        url: `https://m.maoyan.com/ajax/movieOnInfoList`


    })
}
//好评电影
exports.fetchgoodsMovie = function () {
    return request({
        url: `https://m.maoyan.com/ajax/topRatedMovies`
    })
}

//电影详情
exports.fetchdetailedMovie = function (id) {
    return request({
        url: `https://m.maoyan.com/api/mtrade/mmdb/movie/v5/${id}.json`
    })
}

//猫眼推荐
exports.fetchrecommendMovie = function (sortId, showType, limit) {
    let url = `https://m.maoyan.com/ajax/moreClassicList?sortId=${sortId}&showType=${showType}&limit=${limit}`
    return request({
        url
    })
}
// 获取用户想看的电影
exports.fetchWantSeeMovie = function (movieid) {
    return request({
        method: "POST",
        url: `http://127.0.0.1:5566/updSeeMovie`,
        data: {
            movieid
        }
    })
}